import { request } from '@/utils/request.js'
import { transFormData } from '@/utils/transformData'

const baseUrl = `/api/house`

export function _getList(data) {
  data = transFormData(data)
  return request({
    url: baseUrl + '/my',
    method: 'get',
    params: {
      ...data
    }
  })
}

export function _getDetail(id) {
  return request({
    url: baseUrl + '/' + id,
    method: 'get'
  })
}

export function _post(data) {
  data = transFormData(data)
  return request({
    url: baseUrl,
    method: 'post',
    data
  })
}

export function _delete(id) {
  return request({
    url: baseUrl + '/' + id,
    method: 'delete'
  })
}

export function _put(data) {
  const { id } = data

  return request({
    url: baseUrl + '/' + id,
    method: 'put',
    data
  })
}

export function _grounding(id) {
  return request({
    url: baseUrl + '/grounding',
    method: 'patch',
    data: { id }
  })
}

export function _undercarriage(id) {
  return request({
    url: baseUrl + '/undercarriage',
    method: 'patch',
    data: { id }
  })
}
